<template>
	<div>
		<headerNave :nva-datas="navDatas" v-on:backNav="backNav"></headerNave>
		<components :is="currentView" v-on:changeView="changeView" v-on:backPrev="backPrev" :template-obj="templateObj"></components>
	</div>
</template>
<script>
	import $ from 'jquery'
	import headerNave from '../../../../../components/headerNave'
	import { GloabFun, Animation, HttpServer } from '../../../../../assets/js/common.js'
	//图书列表
	const List = resolve => require(['./List.vue'], resolve)
	//图书豆瓣信息
	const DouBanInfo = resolve => require(['./DouBanInfo.vue'], resolve)
	//剔旧列表
	const Pickout = resolve => require(['./PickoutList.vue'], resolve)
	//地图展示
	const bookMap = resolve => require(['./bookMap.vue'], resolve)
	//图书去重
	const deleteBad = resolve => require(['./DeleteBad.vue'], resolve)

	export default {
		components: {
			List,
			DouBanInfo,
			Pickout,
			bookMap,
			deleteBad,
			headerNave
		},
		data() {
			return {
				currentView: "List",
				templateObj: {
					DistrictId: this.subArgs.DistrictId,
					CurrentView: this.subArgs.CurrentView
				},
				navDatas: [{
						name: '图书流通',
						view: ""
					},
					{
						name: '图书管理',
						view: ""
					},
					{
						name: this.subArgs.CurrentView,
						view: "List"
					}
				]
			};
		},
		props: {
			subArgs: {
				type: Object,
				default: {}
			}
		},
		methods: {
			changeView(view, obj) {
				GloabFun.clearRecordPreview.call(this);
				obj.DistrictId = this.subArgs.DistrictId;
				obj.CurrentView = this.subArgs.CurrentView;
				Animation.animation($("#mainContent"), function() {
					if(obj) {
						this.navDatas = [{
								name: '图书流通',
								view: ""
							},
							{
								name: '图书管理',
								view: ""
							},
							{
								name: this.subArgs.CurrentView,
								view: "List"
							}
						];
						this.templateObj = obj;
						if(view === "DouBanInfo") {
							this.navDatas.push({
								name: "图书详情->" + obj.name,
								view: "DouBanInfo"
							});
						} else if(view === "Pickout") {
							this.navDatas.push({
								name: "剔旧列表",
								view: "Pickout"
							});
						} else if(view === "bookMap") {
							this.navDatas.push({
								name: "图书位置->" + obj.name,
								view: "bookMap"
							});
						} else if(view === "deleteBad") {
							this.navDatas.push({
								name: "图书去重",
								view: "deleteBad"
							});
						}
					}
					this.currentView = view;
				}.bind(this));
			},
			backPrev() {
				this.$emit('backPrev');
			},
			backNav(item) {
				if(item.view === "List") {
					// this.changeView("List",{});
					this.changeView("List", this.templateObj);
				}
			}
		}
	}
</script>